package org.linlinjava.litemall.wx.config;

import org.linlinjava.litemall.wx.util.MerchantInterceptor;
import org.linlinjava.litemall.wx.util.MerchantPermissionInterceptor;
import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisConfig {
    @Bean
    MerchantPermissionInterceptor merchantPermissionInterceptor() {
        return new MerchantPermissionInterceptor();
    }

    @Bean
    MerchantInterceptor merchantInterceptor(){
        return new MerchantInterceptor();
    }

    @Bean
    public ConfigurationCustomizer configurationCustomizer(){
        return new ConfigurationCustomizer() {
            @Override
            public void customize(org.apache.ibatis.session.Configuration configuration) {
                configuration.addInterceptor(merchantPermissionInterceptor());
                configuration.addInterceptor(merchantInterceptor());
            }
        };
    }
}
